import os
import subprocess

def checkout():
	os.system("svn checkout svn+ssh://agent00sue@gforge.ucd.ie/var/lib/gforge/chroot/scmrepos/svn/comp41420-1/trunk")

def update(revision_no):
	os.system("svn update -r " + str(revision_no))

def run_test():
	result = os.system("python testChessBoard.py")
	return result

def find_revision(start, end):
	if end == start+1:
		print("The revision that broke the build was "+str(end))
		return
	midpoint = (start+end)/2
	update(midpoint)
	result = run_test()
	if result:
		find_revision(start, midpoint)
	else:
		find_revision(midpoint, end)
	
checkout()
os.chdir("trunk")
find_revision(0,44)

